﻿using RecognitionForm.Handler;
using System;
using System.Linq;
using Xunit;

namespace UnitTestProject
{
    public class UnitTest1
    {
        private DataProvider dataProvider = new DataProvider();


        [Fact]
        public async void TestMethod1()
        {
            StaffInfo model = new StaffInfo
            {
                code = Guid.NewGuid().ToString("N"),
                name = "test",
                gender = "Y",
                birthday = System.DateTime.Now,
                accAuth = 'Y',
                groupId = 1,
                photo = "xxaabcdefg"
            };

            DataProvider dataProvider = new DataProvider();
            var i = await dataProvider.InsertStaffAsync(model);
            Assert.True(i > 0);
        }

        [Fact]
        public async void Insert()
        {
            RecognitionLogInfo model = new RecognitionLogInfo
            {
                code = Guid.NewGuid().ToString("N"),
                staffcode = "cfa8ef5f75184ebc816b4d64249cb0ae",
                age = 30,
                gender = "男",
                recognitionTime = System.DateTime.Now,
                credate = System.DateTime.Now
            };

            var i = await dataProvider.InsertRecognitionLogAsync(model);
            Assert.True(i > 0);
        }

        [Theory]
        [InlineData("cfa8ef5f75184ebc816b4d64249cb0ae")]
        public async void GetName(string guid)
        {
            //string name = await dataProvider.GetStaffName(guid);

            //Assert.Equal(name, "test");
        }

        [Theory]
        [InlineData("cfa8ef5f75184ebc816b4d64249cb0ae", "10:00:13", "11:35:13")]
        public async void GetScalarLog(string code, string startTime, string endTime)
        {
            int result = await dataProvider.GetScalarLog(code, Convert.ToDateTime(startTime), Convert.ToDateTime(endTime));

             Assert.Equal(result, 1);
        }

        [Theory]
        [InlineData("00:00:13", "23:59:59")]
        public async void GetLastLogs(string startTime, string endTime)
        {
            var result = await dataProvider.GetLastLogs(Convert.ToDateTime(startTime), Convert.ToDateTime(endTime));

            Assert.True(result.Count() > 0);
        }

    }
}
